<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .grid-container {
      /* 网格布局 */
      display: inline-grid;
      /* 定义3行，每行高为100px */
      grid-template-rows: repeat(3, 100px);
      /* 定义3列，第列宽为100px */
      grid-template-columns: repeat(3, 100px);
      margin: 100px;
      /* 单元格里面内容对齐方式 */
      justify-items: center;
    }
    /* 每个区域中文字效果 */
    .grid-item {
      font-size: 30px;
      color: red;
    }
    .grid-item:nth-child(n) {
      background-color: skyblue;
    }
    .grid-item:nth-child(2n) {
      background-color: khaki;
    }
  </style>
<body>
    <!-- 
        TIP
        justify-items属性设置单元格内容的水平位置

        stretch	（默认值）拉伸，占满单元格的整个宽度（grid 项未设置宽度时才能看到效果）
        start	 与单元格最左边对齐
        end	     与单元格最右边对齐
        center	 单元格内水平对齐
    -->
    <div class="grid-container">
        <div class="grid-item">1</div>
        <div class="grid-item">2</div>
        <div class="grid-item">3</div>
        <div class="grid-item">4</div>
        <div class="grid-item">5</div>
        <div class="grid-item">6</div>
        <div class="grid-item">7</div>
        <div class="grid-item">8</div>
        <div class="grid-item">9</div>
      </div>
</body>
</html>